﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using CoreEA;

namespace WPF_DbCenter.Utility
{
    /// <summary>
    /// Interaction logic for Utility.xaml
    /// </summary>
    public partial class Utility : Page
    {
        public CoreE.UsedDatabaseType curDbType { get; set; }

        public Utility(CoreE.UsedDatabaseType  dbType)
        {
            curDbType = dbType;
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(this.textBox1.Text))
            {
                MessageBox.Show("Please input the connection string first");
                return;
            }

            string str=textBox1.Text;

            CoreEA.ICoreEAHander core = new CoreEA.CoreE(curDbType).X_Handler;
            try
            {
                core.Open(str);
                if (core.IsOpened)
                {
                    MessageBox.Show("Connection is right");
                }

            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);
            }
        }
    }
}